#include <bits/stdc++.h>

using namespace std;

const int MAXN = 110;

int h, w;
string c[MAXN];

int dp[MAXN][MAXN];

int main() {
    cin >> h >> w;
    for (int i = 1; i <= h ; i++) {
        cin >> c[i];
        c[i] = '$' + c[i];
    }

    if (c[1][1] == '.') dp[1][1]  = 1;

    int mx = dp[1][1];
    for (int i = 1; i <= h; i++) {
        for (int j = 1; j <= w; j++) {
            if (i == 1 && j == 1) continue;
            if (i > 1 && c[i-1][j] == '.') dp[i][j] = max(dp[i][j], dp[i-1][j]);
            if (j > 1 && c[i][j-1] == '.') dp[i][j] = max(dp[i][j], dp[i][j-1]);

            if (dp[i][j] && c[i][j] == '.') dp[i][j] ++;

            mx = max(mx, dp[i][j]);
        }
    }


    cout << mx<< endl;
}